<template>
  <div class="Net_increment">
    <highcharts :options="netchartOptions"></highcharts>
  </div>
</template>

<script>
import { requestJobTimeNetIncrement } from "@/api/index.js";

export default {
  name: "JobTimeNetInrement",
  props: ["netIncreace"],
  data() {
    this.getData();
    return {
      netchartOptions: {
        chart: {
          borderWidth: 0.5,
          borderColor: "#000",
          type: "column"
        },
        title: {
          text: "岗位净增量"
        },
        subtitle: {
          text: "数据来源：redas"
        },
        xAxis: {
          type: "datetime",
          dateTimeLabelFormats: {
            day: "%Y-%m-%d"
          },
          title:{
            text: "日期"
          }
        },
        yAxis: {
          title: {
            text: "岗位增加量"
          }
        },
        // 版权水印
        credits: {
          // enabled: false,
          text: "redas",
          href: "#"
        },
        series: [
          {
            name: "data",
            data: []
          }
        ]
      }
    };
  },
  methods: {
    getData: function() {
      let vue = this;
      let send_data = {
        position: vue.netIncreace.position,
        edu: vue.netIncreace.education,
        exp: vue.netIncreace.experience,
        city: vue.netIncreace.city,
        startDate: vue.netIncreace.startDate,
        endDate: vue.netIncreace.endDate
      };

      requestJobTimeNetIncrement(send_data).then(data => {
        vue.netchartOptions.series[0].data = data.result;
      });
    }
  },
  watch: {
    netIncreace: function(new_data, old_data) {
      if (new_data != "") {
        this.getData();
      }
    }
  }
};
</script>

<style>
.Net_increment {
  margin-top: 20px;
}
</style>
